package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.CabinGrade;
import com.ktgj.flight.service.ICabinGradeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机票字典_舱位等级Controller
 * 
 * @author ruoyi
 * @date 2021-11-05
 */
@ControllerAdvice
@RestController
@RequestMapping("/grade")
public class CabinGradeController extends BaseController
{
    @Autowired
    private ICabinGradeService cabinGradeService;

    /**
     * 查询机票字典_舱位等级列表
     */
    //@PreAuthorize(hasPermi = "flight:grade:list")
    @GetMapping("/list")
    public TableDataInfo list(CabinGrade cabinGrade)
    {
        startPage();
        List<CabinGrade> list = cabinGradeService.selectCabinGradeList(cabinGrade);
        return getDataTable(list);
    }

    /**
     * 导出机票字典_舱位等级列表
     */
    //@PreAuthorize(hasPermi = "flight:grade:export")
    @Log(title = "机票字典_舱位等级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CabinGrade cabinGrade) throws IOException
    {
        List<CabinGrade> list = cabinGradeService.selectCabinGradeList(cabinGrade);
        ExcelUtil<CabinGrade> util = new ExcelUtil<CabinGrade>(CabinGrade.class);
        util.exportExcel(response, list, "机票字典_舱位等级数据");
    }

    /**
     * 获取机票字典_舱位等级详细信息
     */
    //@PreAuthorize(hasPermi = "flight:grade:query")
    @GetMapping(value = "/{cabinGradeId}")
    public AjaxResult getInfo(@PathVariable("cabinGradeId") Long cabinGradeId)
    {
        return AjaxResult.success(cabinGradeService.selectCabinGradeById(cabinGradeId));
    }

    /**
     * 新增机票字典_舱位等级
     */
    //@PreAuthorize(hasPermi = "flight:grade:add")
    @Log(title = "机票字典_舱位等级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CabinGrade cabinGrade)
    {
        return toAjax(cabinGradeService.insertCabinGrade(cabinGrade));
    }

    /**
     * 修改机票字典_舱位等级
     */
    //@PreAuthorize(hasPermi = "flight:grade:edit")
    @Log(title = "机票字典_舱位等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CabinGrade cabinGrade)
    {
        return toAjax(cabinGradeService.updateCabinGrade(cabinGrade));
    }

    /**
     * 删除机票字典_舱位等级
     */
    //@PreAuthorize(hasPermi = "flight:grade:remove")
    @Log(title = "机票字典_舱位等级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cabinGradeIds}")
    public AjaxResult remove(@PathVariable Long[] cabinGradeIds)
    {
        return toAjax(cabinGradeService.deleteCabinGradeByIds(cabinGradeIds));
    }
}
